import {getExternalConfigList as _getExternalConfigList} from "@/api/taskCenter";
import {IExternalConfigItem} from "@/api/modules/taskCenter";

export function useExternalConfigList() {
  const externalConfigList = ref<IExternalConfigItem[]>([])

  const getExternalConfigList = async () => {
    const rs = await _getExternalConfigList({externalType: 'task'})
    if (rs.code === 200) {
      externalConfigList.value = rs.payload ?? []
    }
  }

  const getExternalConfigLabel = (id: number) => {
    return externalConfigList.value.find(config => config.id === id)?.name ?? id
  }

  return {
    externalConfigList,
    getExternalConfigList,
    getExternalConfigLabel
  }
}
